home *** CD-ROM | disk | FTP | other *** search
- Path: char.vnet.net!jason
- From: jason@char.vnet.net (Defender of the Realm)
- Newsgroups: comp.lang.c++
- Subject: Arguments with streams
- Date: 1 Jan 1996 08:27:44 GMT
- Organization: Vnet Internet Access, Charlotte, NC - info@char.vnet.net
- Message-ID: <4c85u1$cga@ralph.vnet.net>
- NNTP-Posting-Host: char.vnet.net
- X-Newsreader: TIN [version 1.2 PL2]
- X-Newsreader: TIN [version 1.2 PL2]
-
- I've got a small problem. I'm working on a C++ library for HTML forms
- and wanted to add the some functionality to 'cout' (ostream), but
- am stumped.
-
- Here's what I want:
-
- cout << A("http://www.vnet.net") << "Vnet" << endA << endl;
-
- ostream& endA (ostream& f)
- { f << "</a>"; return f; };
- ostream& A(ostream& f, char *s)
- { f << "<a " << s << ">"; return f; }
-
- My problem lies with 'A'. Is there any way to say that the first argument
- to the function is the ostream at the beginning of the statement without
- explicitly adding it (ie. cout << A(cout, "htt...") << ... << endl; works).
-
- I've looked briefly at the way setw is implemented both in g++ and MSVC,
- but the code looks over my head =)
-
- Thanks in advance to any pointers you can give.
-
- --Jason
- jason@vnet.net
-